package properties

type CaptchaProperty struct {
	Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"`
	//dev 模式下，允许验证码为固定值: 111111
	UseSolidCode bool `mapstructure:"use-solid-code" json:"use-solid-code" yaml:"use-solid-code"`
	ComplexLevel int  `mapstructure:"complex-level" json:"complex-level" yaml:"complex-level"`

	//单位：s(秒)
	TimeOut   int    `mapstructure:"time-out" json:"time-out" yaml:"time-out"`
	StoreType string `mapstructure:"store-type" json:"store-type" yaml:"store-type"`
	ImgWidth  int    `mapstructure:"img-width" json:"img-width" yaml:"img-width"` // 验证码宽度
	ImgHeight int    `mapstructure:"img-height" json:"img-height" yaml:"img-height"`
	KeyLong   int    `mapstructure:"key-long" json:"key-long" yaml:"key-long"` // 验证码长度
	Source    string `mapstructure:"source" json:"source" yaml:"source"`
}

func (c *CaptchaProperty) GetSource() string {
	if c.Source == "" {
		return "abcdefghijkmnpqrstuvwxyz123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
	}
	return c.Source
}
